<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
      <!--        <el-form-item label="租户编号" prop="tenantId">-->
      <!--          <el-input-->
      <!--            v-model="queryParams.tenantId"-->
      <!--            placeholder="请输入租户编号"-->
      <!--            clearable-->
      <!--            @keyup.enter.native="handleQuery"-->
      <!--          />-->
      <!--        </el-form-item>-->
      <el-form-item label="甲方订单ID" prop="outOrderId">
        <el-input
          v-model="queryParams.outOrderId"
          placeholder="请输入甲方订单ID"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="甲方订单编号" prop="outOrderNo">
        <el-input
          v-model="queryParams.outOrderNo"
          placeholder="请输入甲方订单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="产品名称" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入产品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="还款人姓名" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入还款人姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系电话" prop="mobile">
        <el-input
          v-model="queryParams.mobile"
          placeholder="请输入联系电话"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="身份证号码" prop="idCard">
        <el-input
          v-model="queryParams.idCard"
          placeholder="请输入身份证号码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单状态" prop="orderStatus">
        <el-select
          v-model="queryParams.orderStatus"
          placeholder="请选择订单状态"
          clearable
          @change="handleQuery"
        >
          <el-option
            v-for="option in orderStatusOptions"
            :key="option.value"
            :label="option.label"
            :value="option.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="催收状态" prop="collectionStatus">
        <el-select
          v-model="queryParams.collectionStatus"
          placeholder="请选择催收状态"
          clearable
          @change="handleQuery"
        >
          <el-option
            v-for="option in collectionStatusOptions"
            :key="option.value"
            :label="option.label"
            :value="option.value"
          />
        </el-select>
      </el-form-item>


      <!--        <el-form-item label="逾期天数" prop="overdueDays">-->
      <!--          <el-input-->
      <!--            v-model="queryParams.overdueDays"-->
      <!--            placeholder="请输入逾期天数"-->
      <!--            clearable-->
      <!--            @keyup.enter.native="handleQuery"-->
      <!--          />-->
      <!--        </el-form-item>-->


      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['system:order:add']"
        >新增
        </el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:order:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:order:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:order:export']"
        >导出</el-button>
      </el-col> -->
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange"
    :row-style="{ height: '200px' }"
    >
      <!-- <el-table-column type="selection" width="55" align="center"/> -->
      <!--        <el-table-column label="主键id" align="center" prop="id" />-->
      <!--        <el-table-column label="租户编号" align="center" prop="tenantId" />-->
      <el-table-column label="甲方订单ID" align="center" prop="outOrderId"/>


      <!-- <el-table-column label="字典类型" align="center" :show-overflow-tooltip="true">
      <template slot-scope="scope">
        <router-link :to="'/business/dict-data/index/' + scope.row.id" class="link-type">
          <span>{{ scope.row.outOrderNo }}</span>
        </router-link>
      </template>
      </el-table-column> -->
      <el-table-column label="甲方订单编号" align="center" prop="outOrderNo">
        <template slot-scope="scope">
          <div @click="gorbusinessdata(scope.row.id)" style="color: #1890ff; cursor: pointer;">{{
              scope.row.outOrderNo
            }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="产品名称" align="center" prop="productName"/>
      <!--        <el-table-column label="产品信息Json" align="center" prop="productInfo" />-->
      <el-table-column label="还款人姓名" align="center" prop="customerName"/>
      <el-table-column label="联系电话" align="center" prop="mobile"/>
      <el-table-column label="联系地址" align="center" prop="address"/>
      <el-table-column label="身份证号码" align="center" prop="idCard"/>
      <el-table-column label="身份证正面照片" align="center" prop="idCardFront" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.idCardFront" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="身份证反面照片" align="center" prop="idCardBack" width="100">
        <template slot-scope="scope">
          <image-preview :src="scope.row.idCardBack" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="订单总金额" align="center" prop="totalAmount"/>
      <el-table-column label="已还款金额" align="center" prop="repaidAmount"/>
      <el-table-column label="未还款金额" align="center" prop="unpaidAmount"/>
      <el-table-column label="订单总期数" align="center" prop="totalPeriods"/>
      <el-table-column label="已还款期数" align="center" prop="repaidPeriods"/>
      <el-table-column label="未还款期数" align="center" prop="unpaidPeriods"/>
      <!--        <el-table-column label="还款计划信息json" align="center" prop="repaymentPlan" />-->
      <!--        <el-table-column label="合同地址" align="center" prop="contractUrl" />-->
      <!--        <el-table-column label="风控报告地址" align="center" prop="riskReportUrl" />-->
      <el-table-column label="订单状态" align="center" prop="orderStatus">
        <template slot-scope="scope">
          <el-tag :type=" scope.row.orderStatus==0?
        'info':scope.row.collectionStatus==1?
        '':scope.row.collectionStatus==2?
        'danger':'success'">
        {{ scope.row.orderStatus==0?
        '待还款':scope.row.orderStatus==1?
        '部分还款':scope.row.orderStatus==2?
        '已逾期':'已结清' }}
        </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="逾期天数" align="center" prop="overdueDays"/>
      <!--        <el-table-column label="催收人ID" align="center" prop="userId" />-->
      <el-table-column label="催收状态" align="center" prop="collectionStatus">
        <template slot-scope="scope">
    <el-tag :type=" scope.row.collectionStatus==0?
        'info':scope.row.collectionStatus==1?
        '':scope.row.collectionStatus==2?
        'warning':scope.row.collectionStatus==3
        ?'success':'danger'">
        {{ scope.row.collectionStatus==0?
        '待催收':scope.row.collectionStatus==1?
        '催收中':scope.row.collectionStatus==2?
        '承诺还款':scope.row.collectionStatus==3
        ?'催收成功':'催收失败' }}
      </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="催收次数" align="center" prop="collectionTimes"/>
      <el-table-column label="最后催收时间" align="center" prop="lastCollectionTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastCollectionTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结清金额" align="center" prop="settlementAmount"/>
      <el-table-column label="催收备注" align="center" prop="collectionRemark"/>
      <!-- <el-table-column label="创建部门" align="center" prop="createDept" /> -->
      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="100px">
        <template slot-scope="scope">
          <!--            <el-button-->
          <!--              size="mini"-->
          <!--              type="text"-->
          <!--              icon="el-icon-edit"-->
          <!--              @click="handleUpdate(scope.row)"-->
          <!--              v-hasPermi="['system:order:edit']"-->
          <!--            >更新修改</el-button>-->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-s-custom"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:order:allot']"
          >分配用户
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改催款订单信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <!-- <el-form-item label="租户编号" prop="tenantId">
          <el-input v-model="form.tenantId" placeholder="请输入租户编号" />
        </el-form-item>
        <el-form-item label="甲方订单ID" prop="outOrderId">
          <el-input v-model="form.outOrderId" placeholder="请输入甲方订单ID" />
        </el-form-item> -->
        <el-form-item label="催收状态" prop="collectionStatus">
          <el-select v-model="form.collectionStatus" placeholder="请选择" style="width: 100%;">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="订单状态" prop="orderStatus">
          <el-select v-model="form.orderStatus" placeholder="请选择" style="width: 100%;">
            <el-option
              v-for="item in orderoptions"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="催收备注" prop="collectionRemark">
          <el-input v-model="form.collectionRemark" type="textarea" placeholder="请输入内容"/>
        </el-form-item>
        <el-form-item label="甲方订单编号" prop="outOrderNo">
          <el-input v-model="form.outOrderNo" placeholder="请输入甲方订单编号"/>
        </el-form-item>
        <el-form-item label="产品名称" prop="productName">
          <el-input v-model="form.productName" placeholder="请输入产品名称"/>
        </el-form-item>
        <el-form-item label="还款人姓名" prop="customerName">
          <el-input v-model="form.customerName" placeholder="请输入还款人姓名"/>
        </el-form-item>
        <el-form-item label="联系电话" prop="mobile">
          <el-input v-model="form.mobile" placeholder="请输入联系电话"/>
        </el-form-item>
        <el-form-item label="联系地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入联系地址"/>
        </el-form-item>
        <el-form-item label="身份证号码" prop="idCard">
          <el-input v-model="form.idCard" placeholder="请输入身份证号码"/>
        </el-form-item>
        <el-form-item label="身份证正面照片" prop="idCardFront">
          <image-upload v-model="form.idCardFront"/>
        </el-form-item>
        <el-form-item label="身份证反面照片" prop="idCardBack">
          <image-upload v-model="form.idCardBack"/>
        </el-form-item>
        <el-form-item label="订单总金额" prop="totalAmount">
          <el-input v-model="form.totalAmount" placeholder="请输入订单总金额"/>
        </el-form-item>
        <el-form-item label="已还款金额" prop="repaidAmount">
          <el-input v-model="form.repaidAmount" placeholder="请输入已还款金额"/>
        </el-form-item>
        <el-form-item label="未还款金额" prop="unpaidAmount">
          <el-input v-model="form.unpaidAmount" placeholder="请输入未还款金额"/>
        </el-form-item>
        <el-form-item label="订单总期数" prop="totalPeriods">
          <el-input v-model="form.totalPeriods" placeholder="请输入订单总期数"/>
        </el-form-item>
        <el-form-item label="已还款期数" prop="repaidPeriods">
          <el-input v-model="form.repaidPeriods" placeholder="请输入已还款期数"/>
        </el-form-item>
        <el-form-item label="未还款期数" prop="unpaidPeriods">
          <el-input v-model="form.unpaidPeriods" placeholder="请输入未还款期数"/>
        </el-form-item>
        <el-form-item label="合同地址" prop="contractUrl">
          <el-input v-model="form.contractUrl" placeholder="请输入合同地址"/>
        </el-form-item>
        <el-form-item label="风控报告地址" prop="riskReportUrl">
          <el-input v-model="form.riskReportUrl" placeholder="请输入风控报告地址"/>
        </el-form-item>
        <el-form-item label="逾期天数" prop="overdueDays">
          <el-input v-model="form.overdueDays" placeholder="请输入逾期天数"/>
        </el-form-item>
        <!-- <el-form-item label="催收人ID" prop="userId">
          <el-input v-model="form.userId" placeholder="请输入催收人ID" />
        </el-form-item> -->
        <el-form-item label="催收次数" prop="collectionTimes">
          <el-input v-model="form.collectionTimes" placeholder="请输入催收次数"/>
        </el-form-item>
        <el-form-item label="最后催收时间" prop="lastCollectionTime">
          <el-date-picker clearable
                          v-model="form.lastCollectionTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择最后催收时间"
                          style="width: 100%;"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="结清金额" prop="settlementAmount">
          <el-input v-model="form.settlementAmount" placeholder="请输入结清金额"/>
        </el-form-item>

        <!-- <el-form-item label="创建部门" prop="createDept">
          <el-input v-model="form.createDept" placeholder="请输入创建部门" />
        </el-form-item> -->
        <!-- <el-form-item label="删除标志(0代表存在 2代表删除)" prop="delFlag">
          <el-input v-model="form.delFlag" placeholder="请输入删除标志(0代表存在 2代表删除)" />
        </el-form-item> -->
        <!-- <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="分配用户"
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleClose">
      <el-table
    :data="list"
    border
    style="width: 100%;margin-bottom: 20px;">
    <el-table-column label="甲方订单ID" align="center" prop="outOrderId"/>
    <el-table-column label="甲方订单编号" align="center" prop="outOrderNo"/>
    </el-table>
    <el-form :model="userqueryParams" ref="userqueryForm" size="small" :inline="true"  label-width="68px">
              <el-form-item label="用户名称" prop="userName">
                <el-input v-model="userqueryParams.userName" placeholder="请输入用户名称" clearable style="width: 240px" 
                @keyup.enter.native="getlistUser" />
              </el-form-item>
              <!-- <el-form-item label="用户类型" prop="userType">
              <el-select v-model="userqueryParams.userType" placeholder="请选择用户类型">
                <el-option v-for="dict in userTypeList" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
              </el-select>
            </el-form-item> -->
              <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="getlistUser">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="useresetQuery">重置</el-button>
              </el-form-item>
            </el-form>
      <el-table
    :data="userList"
    border
    height="500"
    style="width: 100%">
    <el-table-column
      prop="dept.deptName"
      label="部门"
      width="180">
    </el-table-column>
    <el-table-column
      prop="userType"
      label="用户类型">
    </el-table-column>
    <el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" /> 
    <el-table-column
      prop="userName"
      label="姓名"
      >
    </el-table-column>
    <el-table-column label="手机号码" align="center"  prop="phonenumber"  />
    <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="100px">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="call(scope.row)"
          >指派
          </el-button>
        </template>
      </el-table-column>
    </el-table>
      <!-- <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="call">确 定</el-button>
      </span> -->
    </el-dialog>
  </div>
</template>

<script>
import {listOrder, getOrder, delOrder, addOrder, updateOrder, update, bindUser} from "@/api/business";
import {listUser} from "@/api/system/user";

export default {
  name: "business",
  data() {
    return {
      // 遮罩层
      loading: true,
      dialogVisible: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 催款订单信息表格数据
      orderList: [],
      options: [
        {
          label: '待催收',
          value: 0
        },
        {
          label: '催收中',
          value: 1
        },
        {
          label: '承诺还款',
          value: 2
        },
        {
          label: '催收成功',
          value: 3
        },
        {
          label: '催收失败',
          value: 4
        },
      ],
      orderoptions: [
        {
          label: '待还款',
          value: 0
        },
        {
          label: '部分还款',
          value: 1
        },
        {
          label: '已逾期',
          value: 2
        },
        {
          label: '已结清',
          value: 3
        },
      ],
      userTypeList:[
        {
          label:'管理员',
          value:'admin'
        },
        {
          label:'员工',
          value:'employee'
        },
        {
          label:'租户',
          value:'tenant'
        }
      ],
      userList: [],
      list:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        tenantId: null,
        outOrderId: null,
        outOrderNo: null,
        productName: null,
        productInfo: null,
        customerName: null,
        mobile: null,
        address: null,
        idCard: null,
        idCardFront: null,
        idCardBack: null,
        totalAmount: null,
        repaidAmount: null,
        unpaidAmount: null,
        totalPeriods: null,
        repaidPeriods: null,
        unpaidPeriods: null,
        repaymentPlan: null,
        contractUrl: null,
        riskReportUrl: null,
        orderStatus: null,
        overdueDays: null,
        userId: null,
        collectionStatus: null,
        collectionTimes: null,
        lastCollectionTime: null,
        settlementAmount: null,
        collectionRemark: null,
        createDept: null,
      },
      userqueryParams:{
        pageNum:1,
        pageSize:1000,
        userType:'employee'
      },
      // 表单参数
      form: {},
      formInline: {
        userId:null,
        id:null
      },
      orderStatusOptions: [
        { value: 0, label: '待还款' },
        { value: 1, label: '部分还款' },
        { value: 2, label: '已逾期' },
        { value: 3, label: '已结清' }
      ],
      collectionStatusOptions: [
        { value: 0, label: '待催收' },
        { value: 1, label: '催收中' },
        { value: 2, label: '承诺还款' },
        { value: 3, label: '催收成功' },
        { value: 4, label: '催收失败' }
      ],
      // 表单校验
      rules: {
        outOrderNo: [
          {required: true, message: "甲方订单编号不能为空", trigger: "blur"}
        ],
        productName: [
          {required: true, message: "产品名称不能为空", trigger: "blur"}
        ],
        customerName: [
          {required: true, message: "还款人姓名不能为空", trigger: "blur"}
        ],
        mobile: [
          {required: true, message: "联系电话不能为空", trigger: "blur"}
        ],
        address: [
          {required: true, message: "联系地址不能为空", trigger: "blur"}
        ],
        idCard: [
          {required: true, message: "身份证号码不能为空", trigger: "blur"}
        ],
        idCardFront: [
          {required: true, message: "身份证正面照片不能为空", trigger: "blur"}
        ],
        idCardBack: [
          {required: true, message: "身份证反面照片不能为空", trigger: "blur"}
        ],
        totalAmount: [
          {required: true, message: "订单总金额不能为空", trigger: "blur"}
        ],
        repaidAmount: [
          {required: true, message: "已还款金额不能为空", trigger: "blur"}
        ],
        unpaidAmount: [
          {required: true, message: "未还款金额不能为空", trigger: "blur"}
        ],
        totalPeriods: [
          {required: true, message: "订单总期数不能为空", trigger: "blur"}
        ],
        repaidPeriods: [
          {required: true, message: "已还款期数不能为空", trigger: "blur"}
        ],
        unpaidPeriods: [
          {required: true, message: "未还款期数不能为空", trigger: "blur"}
        ],
        orderStatus: [
          {required: true, message: "订单状态不能为空", trigger: "change"}
        ],
        overdueDays: [
          {required: true, message: "逾期天数不能为空", trigger: "blur"}
        ],
        collectionStatus: [
          {required: true, message: "催收状态不能为空", trigger: "change"}
        ],
        collectionTimes: [
          {required: true, message: "催收次数不能为空", trigger: "blur"}
        ],
        settlementAmount: [
          {required: true, message: "结清金额不能为空", trigger: "blur"}
        ],
      },
      Inlinerules: {
        userId: [
          {required: true, message: "审批人不能为空", trigger: "change"}
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getlistUser()
  },
  methods: {
    /** 查询催款订单信息列表 */
    getList() {
      this.loading = true;
      listOrder(this.queryParams).then(response => {
        this.orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    getStatusStyle(status) {
      switch (status) {
        case 0:
          return {color: 'yellow', backgroundColor: 'lightsalmon'};
        case 1:
          return {color: 'black', backgroundColor: 'yellow'};
        case 2:
          return {color: 'white', backgroundColor: 'lightcoral'};
        case 3:
          return {color: 'white', backgroundColor: 'green'};
        default:
          return {color: 'white', backgroundColor: 'red'};
      }
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    getlistUser() {
      listUser(this.userqueryParams).then(res => {
        this.userList = res.rows
      })
    },
    useresetQuery(){
      this.userqueryParams={
        pageNum:1,
        pageSize:1000,
        userType:'employee'
      }
      this.getlistUser()
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        tenantId: null,
        outOrderId: null,
        outOrderNo: null,
        productName: null,
        productInfo: null,
        customerName: null,
        mobile: null,
        address: null,
        idCard: null,
        idCardFront: null,
        idCardBack: null,
        totalAmount: null,
        repaidAmount: null,
        unpaidAmount: null,
        totalPeriods: null,
        repaidPeriods: null,
        unpaidPeriods: null,
        repaymentPlan: null,
        contractUrl: null,
        riskReportUrl: null,
        orderStatus: null,
        overdueDays: null,
        userId: null,
        collectionStatus: null,
        collectionTimes: null,
        lastCollectionTime: null,
        settlementAmount: null,
        collectionRemark: null,
        createDept: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加催款订单信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      // const id = row.id || this.ids
      // getOrder(id).then(response => {
      //   this.form = response.data;
      //   this.open = true;
      //   this.title = "修改催款订单信息";
      // });
      this.form = row;
      this.open = true;
      this.title = "修改催款订单信息";
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            update(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrder(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      // const ids = row.id || this.ids;
      // this.$modal.confirm('是否确认删除催款订单信息编号为"' + ids + '"的数据项？').then(function() {
      //   return delOrder(ids);
      // }).then(() => {
      //   this.getList();
      //   this.$modal.msgSuccess("删除成功");
      // }).catch(() => {});
      this.dialogVisible = true
      this.formInline = {
        id: row.id
      }
      this.list=[row]
    },
    call(row) {
      // this.$refs["formInline"].validate(valid => {
      //   if (valid) {
      //     bindUser(this.formInline).then(res => {
      //       this.$modal.msgSuccess("修改成功");
      //       this.dialogVisible = false;
      //       this.getList();
      //     })
      //   }
      // });
      this.formInline.userId=row.userId
           bindUser(this.formInline).then(res => {
            this.$modal.msgSuccess("修改成功");
            this.dialogVisible = false;
            this.getList();
          })
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/order/export', {
        ...this.queryParams
      }, `order_${new Date().getTime()}.xlsx`)
    },
    gorbusinessdata(id) {
      this.$router.push({
        path: '/business/data',
        query: {
          id: id
        }
      })
    }
  }
};
</script>
